<?php

namespace App\Services\Page;

use App\Models\BannerModel;
use App\Models\CategoryModel;
use App\Services\Banner\BannerService;
use Illuminate\Support\Facades\Cache;

class PageService
{
    /**
     * 网站首页数据
     * @return mixed
     */
    public function index()
    {
        $banners = BannerService::list(BannerModel::GENRE_INDEX);
        $category = CategoryModel::query()->where('cur_status',1)
            ->select(['id','name'])
            ->orderBy('sort')->get();
        return compact('banners','category');
    }

    /**
     * 删除指定缓存
     * @param string $key
     */
    public function deleteCache($key='')
    {
        if (!empty($key)){
            Cache::forget($key);
        }
    }

}
